var swiper = [
    { x: -64, s: .83, z: 1 },
    { x: 140, s: 1, z: 2 },
    { x: 338, s: .83, z: 1 },
    { x: 960, s: .83, z: 1 },
    { x: 960, s: .83, z: 1 },
    { x: 960, s: .83, z: 1 },
]

function changeSwiper() {
    var swiperSlides = document.querySelectorAll('.swiper .swiper-wrapper .swiper-slide')
    swiperSlides.forEach(function (item, i) {
        item.style.transform = "translateX(" + swiper[i].x + "px) scale(" + swiper[i].s + ")"
        item.style.zIndex = swiper[i].z
    })
}

//首次要调用一下
changeSwiper() 


//封装next函数
function next() {
    //把数组最后一个值弹出
    var temp = swiper.pop()
    //给追加到最前面
    swiper.unshift(temp)
    changeSwiper() 
}

//封装perv函数
function prev(){
    //把数组第一个值弹出
    var temp = swiper.shift()
    //给追加到最后面
    swiper.push(temp)
    changeSwiper()
}

//获取下一张
var swipernext = document.querySelector('.swiper-next')
swipernext.onclick = function () {
    next()
}

//获取下一张
var swiperprev = document.querySelector('.swiper-prev')
swiperprev.onclick = function(){
    prev()
}

//点击图片切换
document.querySelector('.swiper .swiper-wrapper').onclick = function(evt){
 let e = evt || window.event
 let target = e.target|| e.srcElement

 if(target.parentNode.style.transform.includes('64px')){
     prev()
 }
 if(target.parentNode.style.transform.includes('338px')){
     next()
 }
}
